#!/bin/bash

# 由于这个脚本要在 makefile 下执行 ，echo 命令不适用，测试后请注释 echo 行

DIFFFILES=$(find base_study codec common database jkprotocol qrcode recordserver showWindow storage utils vdev -regex '.*\.\(cpp\|hpp\|cc\|cu\|c\|h\)');
# echo "diff files : $DIFFFILES"

for f in $DIFFFILES;
do
  if [ x"${f%%/*}" == x"third" ] || [ x"${f%%/*}" == x"tools" ];
  then
    continue
  fi
  ext=${f##*.}
  if [ "$ext" == "c" ] || [ "$ext" == "cpp" ] || [ "$ext" == "cc" ] || [ "$ext" == "hpp" ] || [ "$ext" == "h" ];
  then
    clang-format --style=file --verbose -i $f;
  fi
done
